package com.lianjia.sh.se.kafka.client.config;

import org.apache.kafka.common.serialization.StringDeserializer;

/**
 * 消费者统一默认配置
 * Created by yangsp1 on 16/7/29.
 */
public class ClientConsumerDefaultConfig {

    //必须：kafka集群ip配置
    public String bootstrapServers ="localhost:19092";

    //必填：(kafka默认不必须，有默认值，但实际业务中为了防止使用混乱，不允许空）集群消费时，防止重复消费
    // 多个consumer，如果有相同groupId，则相当于队列，只有一个consumer消息，否则为订阅，为同时消费
    public String groupId = "default";

    //自动提交offset
    public Boolean enableAutoCommit = true;

    //offset自动提交频率
    public Long autoCommitIntervalMs = 60 * 1000L;

    //key反序列化器
    public String keyDeserializer = StringDeserializer.class.getName();

    //key反序列化器
    public String valueDeserializer = StringDeserializer.class.getName();

    //统一client
    //public String clientId = "default";

    //一次拉取请求，最小数据量。即：达到此值请求就可以返回，否则等待数据达到此数据量
    public Integer fetchMinBytes = 1;

    //max.poll.records 一次拉取请求最多可以拉取的数据量（配置不要太大，否则耗尽内存）
    public Integer maxPollRecords = 100;

    //request.Timeout.Ms 请求超时时间(不能小于session.timeout.ms and fetch.max.wait.ms ，why?)
    public Integer requestTimeoutMs = 40000;

    public String getBootstrapServers() {
        return bootstrapServers;
    }

    public void setBootstrapServers(String bootstrapServers) {
        this.bootstrapServers = bootstrapServers;
    }

    public String getGroupId() {
        return groupId;
    }

    public void setGroupId(String groupId) {
        this.groupId = groupId;
    }

    public Boolean getEnableAutoCommit() {
        return enableAutoCommit;
    }

    public void setEnableAutoCommit(Boolean enableAutoCommit) {
        this.enableAutoCommit = enableAutoCommit;
    }

    public Long getAutoCommitIntervalMs() {
        return autoCommitIntervalMs;
    }

    public void setAutoCommitIntervalMs(Long autoCommitIntervalMs) {
        this.autoCommitIntervalMs = autoCommitIntervalMs;
    }

    public String getKeyDeserializer() {
        return keyDeserializer;
    }

    public void setKeyDeserializer(String keyDeserializer) {
        this.keyDeserializer = keyDeserializer;
    }

    public String getValueDeserializer() {
        return valueDeserializer;
    }

    public void setValueDeserializer(String valueDeserializer) {
        this.valueDeserializer = valueDeserializer;
    }

    public Integer getFetchMinBytes() {
        return fetchMinBytes;
    }

    public void setFetchMinBytes(Integer fetchMinBytes) {
        this.fetchMinBytes = fetchMinBytes;
    }

    public Integer getMaxPollRecords() {
        return maxPollRecords;
    }

    public void setMaxPollRecords(Integer maxPollRecords) {
        this.maxPollRecords = maxPollRecords;
    }

    public Integer getRequestTimeoutMs() {
        return requestTimeoutMs;
    }

    public void setRequestTimeoutMs(Integer requestTimeoutMs) {
        this.requestTimeoutMs = requestTimeoutMs;
    }
}
